package com.scorpionstudio.girlstoryshop;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.scorpionstudio.girlstoryshop.utils.Variable;


public class BuyScreenActivity extends ScorpionActivity{
	private TextView tvEgmail;
	private EditText edtMessage,edtDiachi,edtSdt;
	String nameClothes,costClothes,keyClothes;
	private static final String EMAIL_ADRESS = "girlstory.vn@gmail.com";
	private static final String EMAIL_SUBJECT = " qua GirlStory App";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_buy);
		initVariable();
	}
	public void initVariable(){
		tvEgmail = (TextView) findViewById(R.id.tv_name_mail);
		edtSdt = (EditText) findViewById(R.id.edt_sdt);
		tvEgmail.setText(EMAIL_ADRESS);
		edtMessage = (EditText) findViewById(R.id.edt_mesage);
		Bundle mGetInfo = getIntent().getExtras();
		nameClothes = mGetInfo.getString(Variable.KEY_NAME_CLOTHES);
		costClothes = mGetInfo.getString(Variable.KEY_COST_CLOTHES);
		keyClothes = mGetInfo.getString(Variable.KEY_CLOTHES);
		edtDiachi = (EditText) findViewById(R.id.edt_diachi);
		edtDiachi.requestFocus();
		edtMessage.setText("Mã sản phẩm : " + keyClothes + "\n" + "Tên sản phẩm :" + nameClothes + "\n" + "Giá sản phẩm :" 
		+ costClothes + "\n");
		
	}
	public void eventBuy(View v){
		String message = edtMessage.getText().toString();
		String msgAdress = "Địa chỉ đặt hàng : " + edtDiachi.getText().toString();
		String numberPhone = "    Số điện thoại liên hệ :" + edtSdt.getText().toString();
		Intent email = new Intent(Intent.ACTION_SEND);
		email.putExtra(Intent.EXTRA_EMAIL, new String[]{ EMAIL_ADRESS});
		email.putExtra(Intent.EXTRA_SUBJECT, "Đặt mua sản phẩm " + nameClothes + EMAIL_SUBJECT);
		email.putExtra(Intent.EXTRA_TEXT, message + msgAdress + numberPhone);
		email.setType("message/rfc822");
		startActivityForResult((Intent.createChooser(email, "Choose an Email client :")),100);
	}
	public void eventBackMain(View v){
		Intent mDetail = new Intent(BuyScreenActivity.this,DetailClothesActivity.class);
		startActivity(mDetail);
		finish();
	}
	@Override
	public void onBackPressed() {
		Intent mDetail = new Intent(BuyScreenActivity.this,DetailClothesActivity.class);
		startActivity(mDetail);
		finish();
	}
}
